package com.pcj.utils;

import lombok.Data;

/**
 * @program: wechat
 * @author: 作者
 * @create: 2022-03-03 14:11
 */
@Data
public class JsonResult {
    /*
     *   200 成功  ；   500  错误，错误信息在msg字段；  501  bean验证错误，不管多少个错误都以map形式返回
     *   502  拦截器拦截到用户token错误 ；  555  异常抛出信息
     */

    private Integer status;
    private String msg;
    private Object data;

    public JsonResult() {

    }

    public JsonResult(Integer status, String msg, Object data) {
        this.status = status;
        this.msg = msg;
        this.data = data;
    }


    public static JsonResult success(Object data) {
        return new JsonResult(data);
    }

    public static JsonResult errorMsg(String msg) {
        return new JsonResult(500, msg, null);
    }

    public JsonResult(Object data) {
        this.status = 200;
        this.msg = "OK";
        this.data = data;
    }

}
